﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WebSilverlightService
{
    // NOTE: If you change the interface name "IWStats" here, you must also update the reference to "IWStats" in Web.config.
    [ServiceContract]
    public interface IWSStats
    {
        /// <summary>
        /// Get the values for an year for a specific subject.
        /// </summary>
        /// <param name="subject">
        /// The subject identifies a type of statistical data. Each data refers to a single month of a year. Possible subjects are:<br/>
        /// "totalPassengers": the number of passengers of overall trips
        /// "savedPollution": the estimated amount of pollution saved by the sytem usage measured in hundreds of kg of CO2
        /// "savedMoney": the estimated amount of money saved measured in EUR.
        /// "savedFuel": the estimated amount of fuel saved measured in liters.
        /// "doneKilometers": the total amount of kilometers of all the trips.
        /// "dailyTripProposed": number of trips proposed by users.
        /// "dailyTripCompleted": number of trips completed.
        /// "missedAppointmentByDrivers": number of passengers that missed a trip because of the driver.
        /// "missedAppointmentByPassengers": number of appointments missed by passengers.
        /// "carriedPassengers": number of passengers carried along the trip.
        /// "registeredUsers": number of registered users.
        /// "averageTripKm": total number of trips kilometers divided by the number of trips.
        /// "maxPassengers": maximum passengers for a single trips.
        /// </param>
        /// <param name="year">the year the data are requested for</param>
        /// <returns>An YearValues containing an array of 12 integers, the requested year and the subject. Each integer is the data for a month.</returns>
        [OperationContract]
        YearValues GetYearStats(string subject, int year);

        /// <summary>
        /// Get the values for a month for a specific subject.
        /// </summary>
        /// <param name="subject">
        /// The subject identifies a type of statistical data. Each data refers to a single day of the month. Possible subjects are:<br/>
        /// "totalPassengers": the number of passengers of overall trips
        /// "savedPollution": the estimated amount of pollution saved by the sytem usage measured in hundreds of kg of CO2
        /// "savedMoney": the estimated amount of money saved measured in EUR.
        /// "savedFuel": the estimated amount of fuel saved measured in liters.
        /// "doneKilometers": the total amount of kilometers of all the trips.
        /// "dailyTripProposed": number of trips proposed by users.
        /// "dailyTripCompleted": number of trips completed.
        /// "missedAppointmentByDrivers": number of passengers that missed a trip because of the driver.
        /// "missedAppointmentByPassengers": number of appointments missed by passengers.
        /// "carriedPassengers": number of passengers carried along the trip.
        /// "registeredUsers": number of registered users.
        /// "averageTripKm": total number of trips kilometers divided by the number of trips.
        /// "maxPassengers": maximum passengers for a single trips.
        /// </param>
        /// <param name="year">the year the data are requested for</param>
        /// <param name="month">the month the data are requested for [1-12]</param>
        /// <returns>An YearValues containing an array of N integers where N is the number of days in the month, the requested year and the subject. Each integer is the data for a day. An array of N integers where N is the number of days in the month. Each integer is the data for a day. E.g, result[0] is the data for the first day of the month.</returns>
        [OperationContract]
        MonthValues GetMonthStats(string subject, int year, int month);
    }

    /// <summary>
    /// Data for a year.
    /// </summary>
    [DataContract]
    public class YearValues
    {
        /// <summary>
        /// The year the data are refered to.
        /// </summary>
        [DataMember]
        public int year { get; set; }

        /// <summary>
        /// The data (each field of the array represents the data for a month, e.g. monthlyData[0] is the data for january)
        /// </summary>
        [DataMember]
        public int[] monthlyData { get; set; }

        /// <summary>
        /// The subject requested for the graph.
        /// </summary>
        [DataMember]
        public string graphSubject { get; set; }

    }

    /// <summary>
    /// Data for a month.
    /// </summary>
    [DataContract]
    public class MonthValues
    {
        /// <summary>
        /// The requested year.
        /// </summary>
        [DataMember]
        public int year { get; set; }

        /// <summary>
        /// The requested month.
        /// </summary>
        [DataMember]
        public int month { get; set; }

        /// <summary>
        /// The data (each field of the array represents the data for a day, e.g. daysData[0] is the data for the first day of the month)
        /// </summary>
        [DataMember]
        public int[] daysData { get; set; }

        /// <summary>
        /// The subject requested for the graph.
        /// </summary>
        [DataMember]
        public string graphSubject { get; set; }

    }

}
